<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <div id="app">
        <!-- is表示默认标签 转换组件 ul li  select == -->
        <!-- <table>
            <tbody>
                <tr is="row"></tr>
                <tr is="row"></tr>
                <tr is="row"></tr>
            </tbody>
        </table> -->

        <!-- ref获取dom节点 this.$refs.hello.innerHTML 获取ref为hello的节点 -->
        <div ref="hello">
            hello
        </div>
        <!-- 组件求和 ref获取组件-->
        <div>
            <counter ref="one" @change="handleChange"></counter>
            <counter ref="two" @change="handleChange"></counter>
            <div>{{total}}</div>
        </div>
    </div>

</body>
<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
<script>
    Vue.component('row', {
        template: '<tr><td>this is a row</td></tr>'
    });
    Vue.component('counter', {
        template: '<div @click="handleClick">{{number}}</div>',
        data:function(){
            return {
                number:0
            }
        },
        methods:{
            handleClick:function(){
                this.number ++;
                this.$emit('change');
            }
        }
    });
    var vm = new Vue({
        el:"#app",
        data(){
            return {
                total:0
            }
            
        },
        methods:{
            handleChange(){
                // this.$refs.one 获取组件ref one
                this.total = this.$refs.one.number + this.$refs.two.number;
                // this.$refs.one.number;
                // this.$refs.two.number;
            }
        }
    })
</script>

</html>